package book_mianshizhinan.test1_7;

public class GETWINDOWMAX {

	public static void main(String[] args) {

		int[] arr = {
				4,3,5,4,3,3,6,7
		};
		int[] result = getwindowmax(arr, 3);
		for(int i = 0;i<result.length;i++){
			System.out.print(result[i]+"  " );
		}
		
	}

	public static int[] getwindowmax(int[] arr, int w) {
		int n = arr.length;
		int[] result = new int[n - w + 1];

		for (int i = 0; i < n - w + 1; i++) {
			result[i] = findTheMax(arr[i], arr[i + 1], arr[i + 2]);
		}

		return result;
	}

	public static int findTheMax(int a, int b, int c) {
		int max = a;
		if (max < b) {
			max = b;
		}
		if (max < c) {
			max = c;
		}

		return max;
	}

}
